<template>
  <div>
    <p v-if="flag">1222</p>
    <p v-else ref="p">1222</p>
    <button @click="fn">点击一下</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      flag: true,
    };
  },
  methods: {
    fn() {
      this.flag = true;
      this.$nextTick(() => {
        console.log(this.$refs.p);
      });
    },
  },
  updated() {
    console.log("更新了");
  },
  mounted() {
    console.log("我挂载了");
  },
};
</script>

<style>
</style>